// template/loginModal/loginModal.js
const app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    hidden:{
      type:Boolean,
      value:false,
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    getUserInfo:function(e){
      let detail = e.detail,
          _this = this;
      if (detail.userInfo) {
        wx.login({
          success: res => {
            app.util.ajax({
              url:"api/Passport/login",
              method:'POST',
              data:{
                encrypted_data:detail.encryptedData,
                iv:detail.iv,
                code:res.code,
                user_info:detail.rawData,
                tk_id:app.globalData.tk_id
              }
            },function(data){
                _this.setData({
                  userInfo:data.data.data
                })
                app.globalData.userInfo = data.data.data;
                _this.triggerEvent("getUserInfo",data.data.data);
                wx.setStorage({
                  key: "userInfo",
                  data: app.globalData.userInfo
                });
                // 分享跳转
              let jump=wx.getStorageSync("jump");
                if (jump) {
                  wx.setStorageSync('jump',"");
                  wx.navigateTo({
                    url:jump
                  })
                }
            })
          }
        });
        this.setData({
          hidden:false
        });
      };
        
    },
    closeModal:function(){

    }
  }
})
